package net.mysoft.budgetsoft.system.action;

import net.mysoft.budgetsoft.system.service.OrgService;
import net.mysoft.framework.base.BaseAction;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

/**
 * 组织机构Action
 * @author kangrui
 *
 */
@Results({@Result(name="tree", location="/platform/budget/org/tree.jsp")
	, @Result(name="list", location="/platform/budget/org/list.jsp")})
@Namespace("/org")
@Scope("prototype")
@Controller
public class OrgAction extends BaseAction {
	
	@Autowired
	private OrgService orgService;

	/**
	 * 
	 */
	private static final long serialVersionUID = -2213850985555164804L;
	
	@Action("tree")
	public String tree() {
		super.getRequest().setAttribute("json", orgService.getOrgTree());
		return "tree";
	}
	
	@Action("datagrid")
	public String datagrid() {
		super.writeJson(orgService.getOrgByPage(getPara("pid"), getParaToInt("page"), getParaToInt("rows")));
		return null;
	}
	
}
